#include "handlergoals.h"
#include "Aria.h"
#include "ArNetworking.h"
#include <QListWidgetItem>

handlerGoals::handlerGoals(QObject *parent,ArClientBase *client) :
    QObject(parent),
    updateGoalsCB(this,&handlerGoals::handlerUpdateGoals)
{

    handledClient = client;

    if(!handledClient->dataExists("getGoals"));
    else{
        handledClient->addHandler("getGoals", &updateGoalsCB);
        handledClient->requestOnce("getGoals");
    }
}


void handlerGoals::handlerUpdateGoals(ArNetPacket *packet){

    char temp[512];
    int len=512;

    emit signal_remove_goals();

    printf("En la funcion goals");

    packet->bufToStr(temp,len);

    while(temp[0] != 0){

        QString goal(temp);
        emit signal_add_goal(goal);
        packet->bufToStr(temp,len);

   }

}
